package com.wanggsx.library.base.mvp;

import android.os.Bundle;
import androidx.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


/**
 *  Created by {wanggsx} on 2017/4/19
 */

public abstract class BaseMVPFragment<AF extends BaseMVPFragment,V extends IView, P extends BasePresenter<AF,V>> extends BaseMainFragment {
    private P mPresenter;
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPresenter = mPresenterCreate();
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    protected abstract P mPresenterCreate();

    public P getPresenter(){
        return mPresenter;
    }

    @Override
    public void onDetach() {
        mPresenter.detachFragmentOrActivity();
        super.onDetach();
    }

}
